{include file="public/head"}
<link rel="stylesheet" href="__module__/flag-icon-css/css/flag-icon.css">
<style>
    .x-body {
        min-width: 1400px;
    }

    body {
        overflow-x: scroll;
    }
    img{
        height: 50px;
    }
</style>
<body>
<div class="x-body">
    <div class="lotus-nav">

        <div class="layui-input-inline">
            <input id="order_no" name="order_no" class="layui-input" placeholder="订单编号" value="{$Think.get.order_no}">
        </div>

        <div class="layui-input-inline layui-form">
            <select name="order_status" id="order_status">
                <option value="">订单状态</option>
                {foreach name="order_status" item="vo" key="key" }
                {if $Think.get.order_status == $key}
                <option value="{$key}" selected>{$vo}</option>
                {else/}
                <option value="{$key}">{$vo}</option>
                {/if}
                {/foreach}
            </select>
        </div>

        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="start" name="start" value="{$Think.get.start}"
                   placeholder="开始日期">
        </div>

        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="end" name="end" value="{$Think.get.end}" placeholder="结束日期">
        </div>

        <div class="layui-input-inline layui-form" style="width: 130px">
            <select name="unit" id="unit" lay-search>
                <option value="">选择统计货币</option>
                {volist name="unit" id="vo"}
                <option value="{$vo.sign}" {if $Think.get.unit== $vo['sign']} selected {/if}>{$vo.name}</option>
                {/volist}
            </select>
        </div>

        <div class="layui-input-inline layui-form">
            <select name="company_id" id="company_id">
                <option value="">公司名称</option>
                {volist name="companys" id="vo"}
                <option value="{$vo.id}" {if $Think.get.company_id== $vo['id']} selected {/if}>{$vo.name}</option>
                {/volist}
            </select>
        </div>

        <button class="layui-btn layui-btn-sm" onclick="search()"><i class="layui-icon layui-icon-search"></i>搜索
        </button>
        <span class="x-right">共有数据:<i class="i_count">{$orders->total()}</i>条
            <button onclick="javascript:location.reload()" class="layui-btn-default ">
                <i class="layui-icon layui-icon-refresh"></i>
            </button>
        </span>

    </div>
    <table class="layui-table">
        <thead>
        <tr>
            <th style="width: 30px;text-align:center">编号</th>
            <th style="width: 80px;text-align:center">国家</th>
            <th style="width: 100px;text-align:center">商品图</th>
            <th style="min-width: 150px">亚马逊订单编号</th>
            <th style="width: 110px;text-align:center">实付价格</th>
            <th style="width: 65px;text-align:center">购买数量</th>
            <th style="width: 60px;text-align:center">状态</th>
            <th style="width: 130px;text-align:center">订单时间</th>
            <th style="width: 130px;text-align:center">所属公司</th>
            <th style="width: 130px;text-align:center">假发货</th>
            <th style="width: 130px;text-align:center">真发货</th>
            <th style="width: 40px;text-align:center">操作</th>
        </thead>
        <tbody>

        {volist name="orders" id="vo"}
        <tr>
            <td style="text-align:center">{$vo.id}</td>
            <td style="text-align:center">
                <span class="label label-default">
                    <span class="flag-icon flag-icon-{php}echo strtolower($store[$vo['shop_id']]['nation_short']){/php}"></span>
                    {$store[$vo['shop_id']]['nation']}
                </span>
            </td>
            <td style="max-height: 100px;text-align:center">
                {if isset($product[$vo['id']]['url'])}
                <img src="{$product[$vo['id']]['url']}" onclick="previewImg(this)">
                {else/}
                <img src="__images__/noimg.png">
                {/if}
            </td>
            <td>{$vo.order_no}</td>
            <td style="text-align:center">{$vo.pay_money}{$vo.coin}</td>
            <td style="text-align:center">{$vo.goods_num}</td>
            <td style="text-align:center">{$order_status[$vo.order_status]|default=''}</td>
            <td style="text-align:center">{$vo['create_time']|date="Y-m-d H:i",###}</td>
            <td>
                {if $vo['company_id'] == 0}
                总公司
                {else/}
                {$companys[$vo['company_id']]['name']|default='未知'}
                {/if}
            </td>
            <td style="text-align:center">
                {if $vo['fake_good_time']>0}<span style="color:#FF5722;">{$vo['fake_good_time']|date="Y-m-d H:i",###}{/if}</span>
            </td>
            <td style="text-align:center">
                {if $vo['true_good_time']>0}<span style="color:#5FB878;">{$vo['true_good_time']|date="Y-m-d H:i",###}{/if}</span>
            </td>
            <td style="text-align:center">
                <button class="layui-btn layui-btn-xs"
                        onclick="x_admin_show('订单详情','amazonInfo.html?id={$vo.id}&company_id={$vo.company_id}')">详情
                </button>
            </td>
        </tr>
        {/volist}

        </tbody>
    </table>
    <div class="page">
        <div>
            {$orders->render()}
        </div>
    </div>
    <div>
        盈利({$Think.get.unit|default='CNY'})：<span style="color: #5FB878">总价：{$total}</span> -
        <span style="color: #01AAED">运费：{$shipping_money}</span> -
        <span style="color: #01AAED">成本：{$goods_money}</span> -
        <span style="color: #01AAED">手续费：{$expend_fee}</span> =
        <span style="color: #FF5722">{$profit}{$Think.get.unit|default='CNY'}</span>
    </div>
</div>
</body>
{include file="public/foot"}
<script>
    function search() {
        var order_no = $("#order_no").val();
        var order_status = $("#order_status").val();
        var unit = $("#unit").val();
        var start = $("#start").val();
        var end = $("#end").val();
        var company_id = $("#company_id").val();
        location.href = "amazon.html?order_no=" + order_no + "&order_status=" + order_status + "&start=" + start + "&end=" + end + "&company_id=" + company_id+ "&unit=" + unit;
    }

    layui.use(['laydate', 'form'], function () {
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });
        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });
</script>
